/**
 * @description json-schema 验证函数
 */

const Ajv = require('ajv')

const ajv = new Ajv()
/**
 * 验证传入的数据是否符合验证规则
 * @method _validate
 * @param {Object} schema 
 * @param {Object} data 
 */
function _validate(schema,data = {}) {

  let valid = ajv.validate(schema,data)
  if(!valid) {
    return ajv.errors[0]
  }
}

module.exports = {
  _validate
}